package com.kylin.commodity.api.web.facade;

import com.kylin.commodity.api.dto.req.NewCommentReqDTO;
import com.kylin.commodity.api.dto.req.QueryCommentReqDTO;
import com.kylin.commodity.api.dto.req.QueryCommodityReqDTO;
import com.kylin.commodity.api.dto.resp.CommentRespDTO;
import com.kylin.commodity.api.dto.resp.CommodityLiteRespDTO;
import com.kylin.commodity.api.dto.resp.CommodityRespDTO;
import com.kylin.shared.common.Pagination;
import com.kylin.shared.common.ResponseWrapper;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 商品开放平台接口
 * @author Damon S.
 * @version v1.0.1
 * @date 2019年10月30日 16:06
 */
@RequestMapping(value = "/api_v1/commodities", produces = MediaType.APPLICATION_JSON_VALUE)
public interface CommodityPlatformFacade {

    @GetMapping
    ResponseWrapper<Pagination<CommodityLiteRespDTO>> listCommodities(
            @Validated QueryCommodityReqDTO queryCommodityReqDTO
    );


    @GetMapping("/{commodityId}")
    ResponseWrapper<CommodityRespDTO> findCommodityById(
            @PathVariable Long commodityId
    );


    @GetMapping("/{commodityId}/description")
    ResponseWrapper<String> findCommodityDescById(
            @PathVariable Long commodityId
    );


    @GetMapping("/{commodityId}/comments")
    ResponseWrapper<Pagination<CommentRespDTO>> findCommentsByCommodityId(
            @PathVariable("commodityId")Long commodityId,
            @Validated QueryCommentReqDTO queryCommentReqDTO
    );


    @PostMapping("/{commodityId}/comments")
    ResponseWrapper<Boolean> attachComment(
            @PathVariable("commodityId")Long commodityId,
            @RequestBody @Validated NewCommentReqDTO newCommentReqDTO
    );


    @DeleteMapping("/{commodityId}/comments/{commentId}")
    ResponseWrapper<Boolean> detachComment(
            @PathVariable("commodityId")Long commodityId,
            @PathVariable("commentId")Long commentId
    );
}
